package com.xge.component_caipu.binder

import com.bumptech.glide.Glide
import com.xge.common_libary.bean.CaiPuListInfoSection
import com.xge.common_libary.view.utils.BaseBindingBinder
import com.xge.common_libary.view.utils.BindingViewHolder
import om.xge.component_caipu.databinding.ItemCaipuContentBinding

abstract class ItemCaiPuContent :
    BaseBindingBinder<CaiPuListInfoSection, ItemCaipuContentBinding>(ItemCaipuContentBinding::inflate) {

    override fun onViewHolderCreated(holder: BindingViewHolder<CaiPuListInfoSection, ItemCaipuContentBinding>) {
        super.onViewHolderCreated(holder)
        holder.itemView.setOnClickListener {
            holder.item?.let {
                onItemClick(it)
            }
        }
    }
        override fun onBindViewHolder(
        holder: BindingViewHolder<CaiPuListInfoSection, ItemCaipuContentBinding>,
        item: CaiPuListInfoSection
    ) {
        holder.run {
            binding.tvName.text = item.name
            binding.tvTag.text = item.tag
            Glide.with(context).load(item.pic).into(binding.ivCover)
        }
    }
    abstract fun onItemClick(item:CaiPuListInfoSection)
}